Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
force-pushed
the
pbrubeck/slate-diag-vector
branch
from
December 2, 2026 16:45
012ddfc to
320b9a7
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI assistance: this pull request was written with Claude Code (Claude Opus 5.5).
Summary
DiagonalTensornow also accepts anAssembledVector, and returns the diagonal matrix that has the vector on its diagonal, asnumpy.diagdoes. The main use is a lumped mass matrix whose inverse is exact at the degrees of freedom shared by two or more cells. The row sums come from UFL, and Slate only turns them into a diagonal matrix:DiagonalTensor(A) A.rank == 2 -> arguments of A, entries A[i, i] + A.rank == 1 -> (arg, arg renumbered as the next argument), entries A[i]Evidence
test_diagonal_tensor_from_assembled_vector_times_tensoruses continuousDQ0 x CG1on a 2-layer extruded mesh, so one degree of freedom is shared by two cells:AssertionError: The tensor must be rank 2.).After: both pass.
test_assemble_tensors.pyandtest_optimise.pypass.Implementation details
DiagonalTensor.argumentsreturns the argument of the vector and a copy of it with the next argument number. For aCofunctionin V*, this is a map from V to V*, as for a mass matrix._slate2gem_diagonalreads the entries from a rank-1 child directly.push_diagstops atAssembledVectorandReciprocal, and no longer raises anAssertionErrorfor them.DiagonalTensorraisesValueErrorfor invalid input, notAssertionError.Inverseof aDiagonalTensoralready lowers to1/a_ii, so.invneeds no new code.Limitations
DiagonalTensorbuilt from anAssembledVectorfollows the same rule asAssembledVector: each cell gets the global values of the vector. Use it in a product with a tensor that is assembled cell by cell. The docstring says this.Tensor(P).T * D.inv * Tensor(P)stays cell-local, as other Slate products do: it does not contain the terms that couple two cells through a shared degree of freedom.BlockAssembledVectorare not tested.Merge Danger
Door: two-way
Blast Radius: small. Only new input is accepted; rank-2 behaviour is unchanged.
🤖 Generated with Claude Code